package org.xs.big_event.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xs.big_event.dao.category.Category;
import org.xs.big_event.service.impl.CategoryService;
import org.xs.big_event.utils.R;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/api/category")
public class    CategoryController {
    @Autowired
    private CategoryService categoryService;
    @PostMapping("/add")
    public R add(@RequestBody Category category) {
        category.setCreateTime(LocalDateTime.now());
        return categoryService.add(category);
    }
    @GetMapping("/list")
    public R list() {
        return categoryService.list();
    }
    @GetMapping("/findail")
    public R findail(@RequestBody Category id) {
        return categoryService.findail(id.getId());
    }
    @PutMapping("/update")
    public R update(@RequestBody Category category) {
        return categoryService.update(category);
    }
}
